export default function click(className) {
	var body = document.querySelector(className)
	var color = ["rgb(57, 37, 233)", "rgb(252, 91,32)", "rgb(0,255,255)", "rgb(127,255,0)", "rgb(255,20,27)",
		"rgb(255,0,255)", "rgb(0,255,76)"
	]; //颜色（随机）
	var index_i = 0;
	var textArr = []
	textArr = ["♥JS♥", "♥CSS♥", "♥html♥", "♥Python♥", "♥C++♥", "♥Java♥"]; //文字内容（轮播）
	document.addEventListener('click', (e) => {
		var new_span = document.createElement('span');
		var baseX = 0,
			baseY = 0;
		var event = event || window.event;
		// 处理兼容
		if (event.pageX || event.pageY) {
			baseX = event.pageX;
			baseY = event.pageY;
		} else if (event.clientX || event.clientY) {
			baseX = event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
			baseY = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}
		new_span.innerText = textArr[index_i];
		new_span.style.position = 'absolute';
		new_span.style.left = baseX - 10 + 'px';
		new_span.style.top = baseY + 'px';
		new_span.style.color = color[parseInt(Math.random() * color.length)];
		new_span.style.fontSize = 20 + 'px' //字体大小
		new_span.style.zIndex = 1000
		new_span.style.cursor = "pointer"
		body.appendChild(new_span);

		index_i++;
		if (index_i > textArr.length - 1) index_i = 0; //通用形式不用修改
		// 定时器1实现字符串上升效果
		var timer = window.setInterval(() => {
			new_span.style.top = parseInt(window.getComputedStyle(new_span, null)['top']) - 2 +
				'px';
			new_span.style.opacity = window.getComputedStyle(new_span, null)['opacity'] - 0.02;
		}, 15);

		// 定时器2实现字符串消失
		let time = window.setTimeout(() => {
			clearTimeout(timer);
			body.removeChild(new_span);
		}, 200);
		// if(time!=null){
		// 	clearTimeout(time)
		// }

	}, false);
}
